package cn.edu.uestc.indoorposition.common;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class PointAndMapContainer {

	private  List<PointAndMap> container = new ArrayList<>();
	private int index = 0;
	public PointAndMapContainer() {}
	
	public void addPointAndMap(PointAndMap pm) {
		container.add(pm);
	}
	
	public List<PointAndMap> getContainer() {
		return this.container;
	}

	public PointAndMap next() {
		
		if (index >= length()) index = 0;
		PointAndMap pm = this.container.get(index);
		++index;
		return pm;
	}
	
	public int length() {
		return container.size();
	}
	
	public String toString() {
		
		StringBuilder string = new StringBuilder();
		for (PointAndMap pm : container) {
			Point point = pm.getPoint();
			string.append("x: " + point.getPositionX() + " y: " + point.getPositionY() + "\n");
			Map<String, Integer> map = pm.getMap();
			for (Map.Entry<String, Integer> entry : map.entrySet()) {
				string.append(entry.getKey() + " ==> " + entry.getValue() + "\n");
			}
			string.append("#########################\n");
		}
		return string.toString();
	}
	
}
